<%-- 
    Document   : searchResults
    Created on : Mar 31, 2013, 10:01:03 PM
    Author     : Farley
--%>
<%@page import="UserManager.ProductManager"%>
<%@page import="UserManager.Product"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="styles/style.css" rel="stylesheet" type="text/css" media="all"/>
        <!-- JS -->
	<script src="script/jquery-1.4.1.min.js" type="text/javascript"></script>	
	<script src="script/jquery.jcarousel.pack.js" type="text/javascript"></script>	
	<script src="script/jquery-func.js" type="text/javascript"></script>	
	<!-- End JS -->
        <title>FooBar Shop!</title>
    </head>
    <body>
     <% 
           Product results = (Product) session.getAttribute("productSearch");
           String checker = request.getParameter("viewdiscontinue");
           int entries = Integer.parseInt(request.getParameter("pageentries"));
           int limit = Integer.parseInt(request.getParameter("pagelimit"));
           int total = 0;
           int[] id = results.getProductIDList();
           String[] title = results.getTitleList();
           String[] summary = results.getSummaryList();
           float[] price = results.getPriceList();
           int[] stock = results.getStockList();
           String[] type = results.getTypeList();
           int[] status = results.getStatusList();
            
            
           
%>
     <!-- Start Shell -->
      <div class="shell">
	<!-- Header -->	
	<div id="header">
		<h1 id="logo"><a href="index.jsp">ALDIGOY</a></h1>	
		
                <!-- Cart -->
		<div id="cart">
                    <%if(session.getAttribute("loggedUserType") == null){ %>
			<a href="#" class="cart-link">Your Shopping Cart</a>
			<div class="cl">&nbsp;</div>
			<span>You must be logged in.</span>
			&nbsp;&nbsp;	
                        <%}%>
                    <%if("Customer".equals(session.getAttribute("loggedUserType"))){ %>
			<a href="#" class="cart-link">Your Shopping Cart</a>
			<div class="cl">&nbsp;</div>
			<span>Welcome, <%= session.getAttribute("loggedName") %>!</span>
			&nbsp;&nbsp;
                        <%}%>
                    <%if("Product Manager - Book".equals(session.getAttribute("loggedUserType"))){ %>
			<a href="#" class="cart-link">Your Shopping Cart</a>
			<div class="cl">&nbsp;</div>
			<span>Welcome, <%= session.getAttribute("loggedName") %>!</span>
			&nbsp;&nbsp;
                        <%}%>
                    <%if("Product Manager - Magazine".equals(session.getAttribute("loggedUserType"))){ %>
			<a href="#" class="cart-link">Your Shopping Cart</a>
			<div class="cl">&nbsp;</div>
			<span>Welcome, <%= session.getAttribute("loggedName") %>!</span>
			&nbsp;&nbsp;
                        <%}%>   
                    <%if("Product Manager - AudioCD".equals(session.getAttribute("loggedUserType"))){ %>
			<a href="#" class="cart-link">Your Shopping Cart</a>
			<div class="cl">&nbsp;</div>
			<span>Welcome, <%= session.getAttribute("loggedName") %>!</span>
			&nbsp;&nbsp;
                        <%}%>   
                    <%if("Product Manager - DVD".equals(session.getAttribute("loggedUserType"))){ %>
			<a href="#" class="cart-link">Your Shopping Cart</a>
			<div class="cl">&nbsp;</div>
			<span>Welcome, <%= session.getAttribute("loggedName") %>!</span>
			&nbsp;&nbsp;
                        <%}%>
                     <%if("Accounting Manager".equals(session.getAttribute("loggedUserType"))){ %>
			<a href="#" class="cart-link">Your Shopping Cart</a>
			<div class="cl">&nbsp;</div>
			<span>Welcome, <%= session.getAttribute("loggedName") %>!</span>
			&nbsp;&nbsp;
                        <%}%>  
		</div>
		<!-- End Cart -->
		
		<!-- Navigation -->
		<div id="navigation">
                    <%if(session.getAttribute("loggedUserType") == null){ %>
			<ul>
			    <li><a href="index.jsp">Home</a></li>
			    <li><a href="register.jsp">Register</a></li>
			    <li><a href="login.jsp">Login</a></li>
			    <li><a href="#">About Us</a></li>
			</ul>
                        <%}%>
                     <%if("Customer".equals(session.getAttribute("loggedUserType"))){ %>
			<ul>
			    <li><a href="loggedin.jsp" class="active">Home</a></li>
			    <li><a href="viewUserServlet">My Account</a></li>
                            <li><a href="logoutServlet">Logout</a></li>
                            <li><a href="#">About Us</a></li>
			</ul>
                      <%}%>
                    <%if("Product Manager - Book".equals(session.getAttribute("loggedUserType"))){ %>
			<ul>
			    <li><a href="bookProductManager.jsp" class="active">Home</a></li>
			    <li><a href="bookAddProduct.jsp">Add Product (Book)</a></li>
                            <li><a href="m_changePassword.jsp">Change Password</a></li>
                            <li><a href="logoutServlet">Logout</a></li>
			</ul>
                      <%}%>
                      <%if("Product Manager - AudioCD".equals(session.getAttribute("loggedUserType"))){ %>
			<ul>
			    <li><a href="bookProductManager.jsp" class="active">Home</a></li>
			    <li><a href="bookAddProduct.jsp">Add Product (Audio CD)</a></li>
                            <li><a href="m_changePassword.jsp">Change Password</a></li>
                            <li><a href="logoutServlet">Logout</a></li>
			</ul>
                      <%}%>
                      <%if("Product Manager - Magazine".equals(session.getAttribute("loggedUserType"))){ %>
			<ul>
			    <li><a href="bookProductManager.jsp" class="active">Home</a></li>
			    <li><a href="bookAddProduct.jsp">Add Product (Magazine)</a></li>
                            <li><a href="m_changePassword.jsp">Change Password</a></li>
                            <li><a href="logoutServlet">Logout</a></li>
			</ul>
                      <%}%>
                      <%if("Product Manager - DVD".equals(session.getAttribute("loggedUserType"))){ %>
			<ul>
			    <li><a href="bookProductManager.jsp" class="active">Home</a></li>
			    <li><a href="bookAddProduct.jsp">Add Product (DVD)</a></li>
                            <li><a href="m_changePassword.jsp">Change Password</a></li>
                            <li><a href="logoutServlet">Logout</a></li>
			</ul>
                      <%}%>
                      <%if("Accounting Manager".equals(session.getAttribute("loggedUserType"))){ %>
			<ul>
			    <li><a href="AccountingManager.jsp" class="active">Home</a></li>
			    <li><a href="viewSales">Manage Sales</a></li>
                            <li><a href="m_changePassword.jsp">Change Password</a></li>
                            <li><a href="logoutServlet">Logout</a></li>
			</ul>
                      <%}%>
                      
                      
		</div>
		<!-- End Navigation -->
	</div>
	<!-- End Header -->
	
	<!-- Main -->
	<div id="main">
		<div class="cl">&nbsp;</div>
		
		<!-- Content  lagay ng if results.getcount <= pagelimit(limit)-->
		<div id="content">
                    <%if(results.getCount() == 0){%> 
                    <b><u>No results found.</b></u>
                    <%}%>
                    
                    <%if(results.getCount() > 0 && "yes".equals(checker)){%> 
                    <div class="box">
                    <b><i><h2>Discontinued Products: Found <%=results.getCount()%> Entries</h2></i></b></div>
                    <%}%>
                    
                    <%if(results.getCount() > 0 && !("yes".equals(checker))){%> 
                    <div class="box">
                    <b><i><h2>Search Results: Found <%=results.getCount()%> Entries</h2></i></b></div>
                    <%}%>
                    
              <%if(results.getCount() > limit){%>
                    <%for(int i = entries; i < limit; i++){%>
                    <table><tr><td>-------------------------------------------------------------------------</td></tr></table>    
                    <strong><a href="viewProductServlet?productid=<%=id[i]%>"><img src="styles/images/products/prod<%=id[i]%>.jpg" alt="" /></a></strong>
                    <table>
                    <tr>
                        <td></td>
                    </tr> 
                    <tr>
                         <%if(status[i] == 0){ %>
                         <td style="color:maroon"><u><b><a href="#">Title </b></u></a></td><td>&nbsp;</td><td><s><%=title[i]%></s></td>
                         <%}%>
                         
                         <%if(status[i] == 1){ %>
                         <td style="color:maroon"><u><b><a href="#">Title </b></u></a></td><td>&nbsp;</td><td><%=title[i]%></td>
                         <%}%>   
                    </tr>
                    <tr>
                         <td style="color:maroon"><u><b>Category </b></u></td><td>&nbsp;</td>
                         <%if("book".equals(type[i])){%>
                         <td>Books</td>
                         <%}%>
                         <%if("magazine".equals(type[i])){%>
                         <td>Magazines</td>
                         <%}%>
                         <%if("audioCD".equals(type[i])){%>
                         <td>Audio CD</td>
                         <%}%>
                         <%if("dvd".equals(type[i])){%>
                         <td>DVD</td>
                         <%}%>
                    </tr>
                    <tr>
                         <td style="color:maroon"><u><b>Price </b></u></td><td>&nbsp;</td><td><%=price[i]%></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    </table>
                    <%total = i;%>
                    <%}%>
                    
                    <%}%>
                    
                    
               <%if(results.getCount() <= limit){%>
                    <%for(int i = entries; i < results.getCount(); i++){%>
                    <table><tr><td>-------------------------------------------------------------------------</td></tr></table>    
                    <strong><a href="viewProductServlet?productid=<%=id[i]%>"><img src="styles/images/products/prod<%=id[i]%>.jpg" alt="" /></a></strong>
                    <table>
                    <tr>
                        <td></td>
                    </tr> 
                    <tr>
                        <%if(status[i] == 0){ %>
                         <td style="color:maroon"><u><b><a href="#">Title </b></u></a></td><td>&nbsp;</td><td><s><%=title[i]%></s></td>
                         <%}%>
                         
                         <%if(status[i] == 1){ %>
                         <td style="color:maroon"><u><b><a href="#">Title </b></u></a></td><td>&nbsp;</td><td><%=title[i]%></td>
                         <%}%>     
                    </tr>
                    <tr>
                         <td style="color:maroon"><u><b>Category </b></u></td><td>&nbsp;</td>
                         <%if("book".equals(type[i])){%>
                         <td>Books</td>
                         <%}%>
                         <%if("magazine".equals(type[i])){%>
                         <td>Magazines</td>
                         <%}%>
                         <%if("audioCD".equals(type[i])){%>
                         <td>Audio CD</td>
                         <%}%>
                         <%if("dvd".equals(type[i])){%>
                         <td>DVD</td>
                         <%}%>
                    </tr>
                    <tr>
                         <td style="color:maroon"><u><b>Price </b></u></td><td>&nbsp;</td><td><%=price[i]%></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    </table>
                    <%total = i;%>
                    <%}%>
                    
                    <%}%>
                    
                    <table>
                    <tr><td>&nbsp;</td></tr>
                    <tr><td>&nbsp;</td></tr>
                    <%if(total <= results.getCount() && entries != 0){%> 
                    <tr><td><b><u><i><a href="nextProductServlet?pageentries=<%=entries-5%>&pagelimit=<%=limit-5%>">&DoubleLeftArrow; PREVIOUS</a></i></u></b></td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <%}%>
                    <%if(results.getCount() > 5 && limit < results.getCount()){%> 
                    <td><b><u><i><a href="nextProductServlet?pageentries=<%=entries+5%>&pagelimit=<%=limit+5%>">NEXT &DoubleRightArrow;</a></i></u></b></td>
                    </tr>
                    <tr><td>&nbsp;</td></tr>
                    <%}%>
                    </table>
                    <%if(results.getCount() != 0){%>
                    <div class="box"
                         <p><i><h2>Entries <%=entries+1%> - <%=total+1%> of  <%=results.getCount()%></h2></i></p></div>
                    <%}%>
		</div>
		<!-- End Content -->
		
		<!-- Sidebar -->
		<div id="sidebar">
			
			<!-- Search -->
			<div class="box search">
				<h2>Search by <span></span></h2>
				<div class="box-content">
					<form action="searchProductServlet" method="post">
						
						<label>Keyword</label>
						<input type="text" class="field" name="searchKeyword" />
						
						<label>Category</label>
						<select class="field" name="searchCategory">
							<option value="All Categories">All Categories</option>
                                                        <option value="book">Books</option>
                                                        <option value="magazine">Magazines</option>
                                                        <option value="audioCD">Audio CD</option>
                                                        <option value="dvd">DVD</option>
						</select>
						
						
						<input type="submit" class="search-submit" value="Search" />
						
						<p>
							<a href="#" class="bul">Advanced search</a><br />
							<a href="#" class="bul">Contact Customer Support</a>
						</p>
	
					</form>
				</div>
			</div>
			<!-- End Search -->
			
			<!-- Categories -->
			<div class="box categories">
				<h2>Categories <span></span></h2>
				<div class="box-content">
					<ul>
					    <li><a href="viewCategoryServlet?productCategory=book">Books</a></li>
					    <li><a href="viewCategoryServlet?productCategory=magazine">Magazines</a></li>
					    <li><a href="viewCategoryServlet?productCategory=audioCD">Audio CD</a></li>
					    <li><a href="viewCategoryServlet?productCategory=dvd">DVD</a></li>
                                            <li><a href="viewCategoryServlet?productCategory=all">View All Products</a></li>
                                            <%if("Product Manager - Book".equals(session.getAttribute("loggedUserType"))){%>
                                            <li class="last"><a href="viewDiscontinued">View Discontinued Products</a></li>
                                            <%}%>
                                            <%if("Product Manager - Magazine".equals(session.getAttribute("loggedUserType"))){%>
                                            <li class="last"><a href="viewDiscontinued">View Discontinued Products</a></li>
                                            <%}%>
                                            <%if("Product Manager - DVD".equals(session.getAttribute("loggedUserType"))){%>
                                            <li class="last"><a href="viewDiscontinued">View Discontinued Products</a></li>
                                            <%}%>
                                            <%if("Product Manager - AudioCD".equals(session.getAttribute("loggedUserType"))){%>
                                            <li class="last"><a href="viewDiscontinued">View Discontinued Products</a></li>
                                            <%}%>
					</ul>
				</div>
			</div>
			<!-- End Categories -->
			
		</div>
		<!-- End Sidebar -->
		
		<div class="cl">&nbsp;</div>
	</div>
	<!-- End Main -->
	
	<!-- Side Full -->
	<div class="side-full">
		
		<!-- More Products -->
		<div class="more-products">
			<div class="more-products-holder">
				<ul>
				    <li><a href="#"><img src="styles/images/prod1.jpg" alt="" /></a></li>
				    <li><a href="#"><img src="styles/images/prod2.jpg" alt="" /></a></li>
				    <li><a href="#"><img src="styles/images/prod3.jpg" alt="" /></a></li>
				    <li><a href="#"><img src="styles/images/prod4.jpg" alt="" /></a></li>
				    <li><a href="#"><img src="styles/images/prod5.jpg" alt="" /></a></li>
				    <li><a href="#"><img src="styles/images/prod6.jpg" alt="" /></a></li>
                                    <li><a href="#"><img src="styles/images/prod8.jpg" alt="" /></a></li>
				    <li><a href="#"><img src="styles/images/prod9.jpg" alt="" /></a></li>
				    <li><a href="#"><img src="styles/images/prod10.jpg" alt="" /></a></li>
				    <li><a href="#"><img src="styles/images/prod11.jpg" alt="" /></a></li>
				    <li class="last"><a href="#"><img src="styles/images/prod7.jpg" alt="" /></a></li>
				</ul>
			</div>
			<div class="more-nav">
				<a href="#" class="prev">previous</a>
				<a href="#" class="next">next</a>
			</div>
		</div>
		<!-- End More Products -->
		
		<!-- Text Cols -->
		<div class="cols">
			<div class="cl">&nbsp;</div>
			<div class="col">
				<h3 class="ico ico1">Fast Delivery</h3>
				<p>We offer one of the fastest delivery services in the whole world.</p>
				<p class="more"><a href="#" class="bul">Learn more</a></p>
			</div>
			<div class="col">
				<h3 class="ico ico2">Customer Service</h3>
				<p>Inquire and learn more about products by talking with our friendly staff.</p>
				<p class="more"><a href="#" class="bul">Learn more</a></p>
			</div>
			<div class="col">
				<h3 class="ico ico3">Gift Service</h3>
				<p>Browsing for a gift? Look no further, we offer one of the safest and most incredible services out there.</p>
				<p class="more"><a href="#" class="bul">Learn more</a></p>
			</div>
			<div class="col col-last">
				<h3 class="ico ico4">Shopping Cart</h3>
				<p>Got everything that you're looking for? Checkout your shopping cart now!.</p>
				<p class="more"><a href="#" class="bul">Finish Shopping</a></p>
			</div>
			<div class="cl">&nbsp;</div>
		</div>
		<!-- End Text Cols -->
		
	</div>
	<!-- End Side Full -->
	
	<!-- Footer -->
	<div id="footer">
		<p class="left">
			<a href="#">Home</a>
			<span>|</span>
			<a href="#">Register</a>
			<span>|</span>
			<a href="#">Login</a>
			<span>|</span>
			<a href="#">About Us</a>
			<span>|</span>
			
		</p>
		<p class="right">
			&copy; 2013 FooBar Shop.
			
		</p>
	</div>
	<!-- End Footer -->
	
</div>	
<!-- End Shell -->
      
      
      
      
    </body>
</html>
